/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Control;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import org.primefaces.model.UploadedFile;

/**
 *
 * @author Chien
 */
@ManagedBean
@RequestScoped
public class FileUploadController {

    /**
     * Creates a new instance of FileUploadController
     */
    private UploadedFile file;

    public UploadedFile getFile() {
        return file;
    }

    public void setFile(UploadedFile file) {
        this.file = file;
    }
    public void upload() {  
        if(file != null) {  
            FacesMessage msg = new FacesMessage("Succesful", file.getFileName() + " is uploaded.");  
            FacesContext.getCurrentInstance().addMessage(null, msg);  
        }  
    }
      
    
    public FileUploadController() {
        
    }
}
